__author__ = 'm0rniac'

from . import tools
from . import constants as c
from .states import main_menu, load_screen, level


def main():
    '''真实的入口函数，负责初始化游戏状态和运行control的主循环。'''
    game = tools.Control()

    # Create a dictionary mapping state names to their respective state instances
    state_dict = {
        c.MAIN_MENU: main_menu.Menu(),
        c.LOAD_SCREEN: load_screen.LoadScreen(),
        c.LEVEL: level.Level(),
        c.GAME_OVER: load_screen.GameOver(),
        c.TIME_OUT: load_screen.TimeOut(),
    }

    # Setup the states of the game using the state dictionary and set the initial state to 'MAIN_MENU'
    game.setup_states(state_dict, c.MAIN_MENU)

    # Start the main game loop
    game.main()
